import * as echarts from 'echarts';

type EChartsOption = echarts.EChartsOption;
const idata = [
  {
    name: 'Breaking学费',
    value: 1000
  },
  {
    name: 'Jazz学费',
    value: 1000
  },
  {
    name: '其他学费',
    value: 1000
  }
];
const odata = [
  {
    name: '场地租赁',
    value: 1000
  },
  {
    name: '礼品',
    value: 500
  },
  {
    name: '日常消费',
    value: 500
  }
];

export const useFinance2Charts = () => {
  const title = '收支占比';
  const option: EChartsOption = {
    title: [
      {
        text: title
      },
      {
        subtext: '收入占比',
        left: '25%',
        top: '80%',
        textAlign: 'center'
      },
      {
        subtext: '支出占比',
        left: '75%',
        top: '80%',
        textAlign: 'center'
      }
    ],
    series: [
      {
        type: 'pie',
        radius: '25%',
        center: ['50%', '50%'],
        data: idata,
        label: {
          position: 'outer',
          alignTo: 'edge',
          margin: 100
        },
        right: '50%',
        top: 0,
        bottom: 0
      } as any,
      {
        type: 'pie',
        radius: '25%',
        center: ['50%', '50%'],
        data: odata,
        label: {
          position: 'outer',
          alignTo: 'edge',
          margin: 100
        },
        left: '50%',
        top: 0,
        bottom: 0
      }
    ]
  };
  return { option };
};
